package com.demo.java.java.util;

import java.util.Iterator;
import java.util.Objects;
import java.util.function.Consumer;

public interface MyIterator<E> extends Iterator<E> {
    /**
     * Returns {@code true} if the iteration has more eleemnts
     *
     * @return
     */
    boolean hashNext();

    E next();

    default void remove() {
        throw new UnsupportedOperationException("remove");
    }

    default void forEachRemaining(Consumer<? super E> action) {
        Objects.requireNonNull(action);
        while (hashNext()) {
            action.accept(next());
        }
    }

}
